<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="../scripts/ext-3.3.1/resources/css/ext-all.css"/>
	<link rel="stylesheet" type="text/css" href="../scripts/jquery-ui-1.8.16/jquery-ui-1.8.16.custom.css" />
	<link rel="stylesheet" type="text/css" href="../styles/global.css"/>
	<link rel="stylesheet" type="text/css" href="../styles/elements.css"/>
	<link rel="stylesheet" type="text/css" href="../styles/table.css"/>
	<script type="text/javascript" src="../scripts/jquery-ui-1.8.16/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="../scripts/jquery-ui-1.8.16/jquery-ui-1.8.16.custom.min.js"></script>
	<script type="text/javascript" src="../scripts/ext-3.3.1/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="../scripts/ext-3.3.1/ext-all.js"></script>
	<script type="text/javascript" src="../scripts/extjs-plus.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			var page = parseInt($("#p_z").val());
			loadZhangData(page,"z");
			loadZhangData(page,"d");
		});
		function zhang(flag){
			var page = parseInt($("#p_z").val());
			if(flag=='next'){
				loadZhangData(page+1,"z");
			}else if(flag=='prev'){
				loadZhangData(page-1,"z");
			}
		}
		function die(flag){
			var page = parseInt($("#p_d").val());
			if(flag=='next'){
				loadZhangData(page+1,"d");
			}else if(flag=='prev'){
				loadZhangData(page-1,"d");
			}
		}
		function loadZhangData(page,flag){
			var url = null;
			var appendTo = null;
			var p = null;
			var next = null;
			var prev = null;
			if(flag=="z"){
				url = "<s:url action="lxzdg_z"/>?page="+page;
				appendTo = "#zhangbody";
				p = "#p_z";
				next = "#z_next_page";
				prev = "#z_prev_page";
			}else{
				url = "<s:url action="lxzdg_d"/>?page="+page;
				appendTo = "#diebody";
				p = "#p_d";
				next = "#d_next_page";
				prev = "#d_prev_page";
			}
			$.getJSON(url,function(res){
				if(res.data.length>0){
					$(appendTo).empty();
					$.each(res.data,function(index,value){
						var html = "<td align='center'>"+((page-1)*10+index+1)+"</td>";
						html+="<td align='center'><a href='#u' onclick=\"showWindow('','<s:url action='profile'/>?gpdm="+value.gpdm+"','900','400')\">"+value.gpmc+"</a></td>";
						html+="<td align='center'>"+value.rqmin+"</font></td>";
						html+="<td align='center'>"+value.rqmax+"</font></td>";
						html+="<td align='center'><font color='red'>"+value.rqcount+"</font>&nbsp;天</td>";
						if(flag=="z"){
							html+="<td align='right' style='color:red;'>"+value.zdf+"%</td>";
						}else{
							html+="<td align='right' style='color:green;'>"+value.zdf+"%</td>";
						}
	
						$("<tr>",{
							"html":html
						}).appendTo(appendTo);
					});
					$(p).val(page);
					var count = res.count;
					var count2 = (10*(page-1)+res.data.length);
					if(count2>=count){//已经是最后一页了，下一页不能点击
						$(next).css("color","gray");
						$(next).unbind("click");
						$(prev).css("color","blue");
						$(prev).unbind("click");
						if(flag="z"){
							$(prev).bind("click",function(){zhang('prev');},false);
						}else{
							$(prev).bind("click",function(){die('prev');},false);
						}
					}else if(page<=1){//第一页，上一页不能点击
						$(next).css("color","blue");
						$(next).unbind("click");
						if(flag="z"){
							$(next).bind("click",function(){zhang('next');},false);
						}else{
							$(next).bind("click",function(){die('next');},false);
						}
						$(prev).css("color","gray");
						$(prev).unbind("click");
					}else{//中间也，都能点击
						$(next).css("color","blue");
						$(next).unbind("click");
						if(flag="z"){
							$(next).bind("click",function(){zhang('next');},false);
						}else{
							$(next).bind("click",function(){die('next');},false);
						}
						$(prev).css("color","blue");
						$(prev).unbind("click");
						if(flag="z"){
							$(prev).bind("click",function(){zhang('prev');},false);
						}else{
							$(prev).bind("click",function(){die('prev');},false);
						}
					}
				}
				
			});
		}
	</script>
	<style>
	body{
		width:600px;
		margin:20px auto;
	}
	table.tb1{
		width:100%;
	}
	table.tb1 tr th,td{
		padding: 2px 5px;
	}
	</style>
</head>
<body>
<input type="hidden" id="p_z" value="1">
<input type="hidden" id="p_d" value="1">
<div style="border-bottom:5px solid red;padding:5px;margin-bottom:5px;font-size:14px;color:red;font-weight:bold">连续上涨股一览</div>
<table class="tb1">
	<thead><th>序号</th><th>股票代码</th><th>日期起</th><th>日期止</th><th>上涨天数</th><th>涨幅</th></thead>
	<tbody id="zhangbody">
	</tbody>
	<tfoot>
	<tr><td colspan="6" align="right"><a id="z_prev_page" href="#u" onclick="zhang('prev')">上一页</a>&nbsp;&nbsp;<a id="z_next_page" href="#u" onclick="zhang('next')">下一页</a></td></tr>
	</tfoot>
</table>
<div style="border-bottom:5px solid green;padding:5px;margin-bottom:5px;font-size:14px;color:green;font-weight:bold">连续下跌股一览</div>
<table class="tb1">
	<thead><th>序号</th><th>股票代码</th><th>日期起</th><th>日期止</th><th>下跌天数</th><th>跌幅</th></thead>
	<tbody id="diebody">
	</tbody>
	<tfoot>
	<tr><td colspan="6" align="right"><a id="d_prev_page" href="#u" onclick="die('prev')">上一页</a>&nbsp;&nbsp;<a id="d_next_page" href="#u" onclick="die('next')">下一页</a></td></tr>
	</tfoot>
</table>
</body>
</html>